package org.example.product.client.service;

import org.example.product.api.model.ProductModel;
import org.example.product.api.service.ProductRemoteService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@FeignClient(value = "PRODUCT-SERVICE", fallback = ProductClient.HystrixClientFallback.class)
public interface ProductClient extends ProductRemoteService {

    @Component
    public static class HystrixClientFallback implements ProductClient {
        @Override
        public ResponseEntity<List<ProductModel>> list() {
            System.out.println("------------------hystrix------------------");
            return ResponseEntity.badRequest().build();
        }
    }

}
